namespace ClassyBlog.Web.Specs.Unit
{
    using Machine.Specifications;

    [Subject(typeof(Pagination))]
    public class when_page_number_is_null
    {
        static int startIndex;

        Because of = () => startIndex = Pagination.StartIndex(null, 10);

        It should_return_zero_as_start_index = () => startIndex.ShouldEqual(0);
    }

    [Subject(typeof(Pagination))]
    public class when_page_number_is_one_and_page_size_is_ten
    {
        static int startIndex;

        Because of = () => startIndex = Pagination.StartIndex(1, 10);

        It should_return_zero_as_start_index = () => startIndex.ShouldEqual(0);
    }

    [Subject(typeof(Pagination))]
    public class when_page_number_is_two_and_page_size_is_ten
    {
        static int startIndex;

        Because of = () => startIndex = Pagination.StartIndex(2, 10);

        It should_return_ten_as_start_index = () => startIndex.ShouldEqual(10);
    }

    [Subject(typeof(Pagination))]
    public class when_page_number_is_six_and_page_size_is_five
    {
        static int startIndex;

        Because of = () => startIndex = Pagination.StartIndex(6, 5);

        It should_return_twenty_five_as_start_index = () =>
            startIndex.ShouldEqual(25);
    }

    [Subject(typeof(Pagination))]
    public class when_total_is_zero
    {
        static int pageCount;

        Because of = () => pageCount = Pagination.PageCount(0, 10);

        It should_return_one_as_page_count = () => pageCount.ShouldEqual(1);
    }

    [Subject(typeof(Pagination))]
    public class when_page_size_is_zero
    {
        static int pageCount;

        Because of = () => pageCount = Pagination.PageCount(100, 0);

        It should_return_one_as_page_count = () => pageCount.ShouldEqual(1);
    }

    [Subject(typeof(Pagination))]
    public class when_total_is_fifty_and_page_size_is_ten
    {
        static int pageCount;

        Because of = () => pageCount = Pagination.PageCount(50, 10);

        It should_return_five_as_page_count = () => pageCount.ShouldEqual(5);
    }

    [Subject(typeof(Pagination))]
    public class when_total_is_senventy_seven_and_page_size_is_five
    {
        static int pageCount;

        Because of = () => pageCount = Pagination.PageCount(77, 5);

        It should_return_sixteen_as_page_count = () =>
            pageCount.ShouldEqual(16);
    }
}